#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace Osh.Teletext
{
	public class TeletextPacket
	{
		public const int MinPacketNumber = 0;
		public const int MaxPacketNumber = 31;

		private byte _magazine;
		private byte _number;

		public TeletextPacket(int magazine, int number)
		{
			if(magazine < TeletextMagazine.MinMagazineNumber || magazine > TeletextMagazine.MaxMagazineNumber)
				throw new ArgumentOutOfRangeException("magazine");
			if(number < MinPacketNumber || number > MaxPacketNumber)
				throw new ArgumentOutOfRangeException("number");
			_magazine = (byte)magazine;
			_number = (byte)number;
		}

		/// <summary>
		/// Magazine number (X/ or M/) in 0 to 7 range.
		/// </summary>
		public int Magazine
		{
			get { return _magazine; }
			set
			{
				if(value < TeletextMagazine.MinMagazineNumber || value > TeletextMagazine.MaxMagazineNumber)
					throw new ArgumentOutOfRangeException("Magazine");
				_magazine = (byte)value;
			}
		}

		/// <summary>
		/// Packet number (Y) in 0 to 31 range.
		/// </summary>
		public int Number
		{
			get { return _number; }
			set
			{
				if(value < MinPacketNumber || value > MaxPacketNumber)
					throw new ArgumentOutOfRangeException("Number");
				_number = (byte)value;
			}
		}
	}

}
